<template>
  <div>
    <h3 style="text-align: center;">
      编辑信息
    </h3>
    <div style="height: 0; margin-bottom: 10px; border-bottom: 1px solid #ccc;"></div>
    <el-form
      label-position="top"
      label-width="auto"
      :model="data"
    >
      <el-form-item label="节点ID">
        <el-input v-model="data.id" disabled />
      </el-form-item>
      <el-form-item label="名称">
        <el-input v-model="data.label" />
      </el-form-item>
      <el-form-item label="描述">
        <el-input v-model="data.data.description" type="textarea" />
      </el-form-item>
      <el-form-item label="参数">
        <el-input v-model="data.data.params" type="textarea" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue'

const props = defineProps(['modelValue'])

const emit = defineEmits(['update:model-value'])

const data = ref({
  id: '',
  label: '',
  data: {
    description: '',
    params: ''
  }
})

// 监听传进来的modelValue, 并给data赋值
watch(() => props.modelValue, (nv, ov) => {
  data.value = nv
}, { deep: true } )
// 监听data的变化, 并实时更新modelValue, 实现响应式
watch(data, (nv, ov) => {
  emit('update:model-value', nv)
}, { deep: true })
</script>

<style scoped lang="scss">

</style>